package jmu.edu.cn.action;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import jmu.edu.cn.domain.User;
import jmu.edu.cn.service.UserService;
import jmu.edu.cn.service.UserServiceImpl;

public class UserAction extends BaseAction {
	private User user = new User();
	private List<User> userList = new ArrayList<User>();
	
	private File excel;
	private String excelFileName;
	private String excelContentType;
	
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<User> getUserList() {
		return userList;
	}

	public void setUserList(List<User> userList) {
		this.userList = userList;
	}
	
	public File getExcel() {
		return excel;
	}

	public void setExcel(File excel) {
		this.excel = excel;
	}

	public String getExcelFileName() {
		return excelFileName;
	}

	public void setExcelFileName(String excelFileName) {
		this.excelFileName = excelFileName;
	}

	public String getExcelContentType() {
		return excelContentType;
	}

	public void setExcelContentType(String excelContentType) {
		this.excelContentType = excelContentType;
	}

	public String toReg() throws Exception{
		return "reg_page";
	}
	public String reg() throws Exception{
		
		return null;
	}

	public String loadAll() throws Exception {
		UserService service = new UserServiceImpl();
		userList = service.loadUser();
		return "list_page";
	}

	public String removeUsr() throws Exception {
		UserService service = new UserServiceImpl();
		service.removeUser(user.getUserNo());
		return "loadAllAct";
	}

	public String toUpdate() throws Exception {
		UserService service = new UserServiceImpl();
		user=service.getUserByNo(user.getUserNo());
		return "update_page";
	}

	public String updateUsr() throws Exception {
		UserService service = new UserServiceImpl();
		service.updateUser(user);
		return "loadAllAct";
	}

}
